package com.gitee.wsl.security.hash.bcrypt


/**
 * Factory for default [LongPasswordStrategy] implementations
 */
object LongPasswordStrategies {
    /**
     * See [LongPasswordStrategy.TruncateStrategy]
     *
     * @param version required to get the max allowed pw length
     * @return new instance
     */
    fun truncate(version: BCrypt.Version): LongPasswordStrategy {
        return LongPasswordStrategy.TruncateStrategy(version.allowedMaxPwLength)
    }

    /**
     * See [LongPasswordStrategy.Sha512DerivationStrategy]
     *
     * @param version required to get the max allowed pw length
     * @return new instance
     */
    fun hashSha512(version: BCrypt.Version): LongPasswordStrategy {
        return LongPasswordStrategy.Sha512DerivationStrategy(version.allowedMaxPwLength)
    }

    /**
     * See [LongPasswordStrategy.StrictMaxPasswordLengthStrategy]
     *
     * @param version required to get the max allowed pw length
     * @return new instance
     */
    fun strict(version: BCrypt.Version): LongPasswordStrategy {
        return LongPasswordStrategy.StrictMaxPasswordLengthStrategy(version.allowedMaxPwLength)
    }

    /**
     * See [LongPasswordStrategy.PassThroughStrategy]
     *
     * @return new instance
     */
    fun none(): LongPasswordStrategy {
        return LongPasswordStrategy.PassThroughStrategy()
    }
}
